/**
 * 
 */
package com.designpattern.design.factory.easyfactory;

import com.designpattern.design.factory.nofactory.CheesePizza;
import com.designpattern.design.factory.nofactory.GreekPizza;
import com.designpattern.design.factory.nofactory.Pizza;

/**
 * 简单工厂模式-生成pizza的工厂
 * 
 * @author zhangyang
 *
 */
public class SimplePizzaFactory {

	public Pizza createPizza(String type) {
		System.out.println("使用简单工厂类创建pizza");
		// pizza对象
		Pizza pizza = null;
		if ("greek".equals(type)) {
			pizza = new GreekPizza();
			pizza.setName("希腊披萨");
		} else if ("cheese".equals(type)) {
			pizza = new CheesePizza();
			pizza.setName("cheese披萨");
		} else {
			System.out.println("当前披萨种类不存在");
			return null;
		}
		return pizza;
	}
	public static Pizza createPizza2(String orderType) {
		System.out.println("使用简单工厂类创建pizza");
		// pizza对象
		Pizza pizza = null;
		if ("greek".equals(orderType)) {
			pizza = new GreekPizza();
			pizza.setName("希腊披萨");
		} else if ("cheese".equals(orderType)) {
			pizza = new CheesePizza();
			pizza.setName("cheese披萨");
		} else {
			System.out.println("当前披萨种类不存在");
			return null;
		}
		return pizza;
	}
	
}
